#include "StdAfx.h"
#include "ThreadLock.h"
// #include "LogTool.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

CThreadLock::CThreadLock(void)
{
	InitializeCriticalSection(&m_cs); 
}

CThreadLock::~CThreadLock(void)
{ 
	DeleteCriticalSection(&m_cs);
}

void CThreadLock::Lock(const char* sFilename, int nLine)
{
	EnterCriticalSection(&m_cs);
}

void CThreadLock::UnLock(const char* sFilename, int iLine)
{
	LeaveCriticalSection(&m_cs);
}

CScopedLock::CScopedLock(CThreadLock &lock, const char* sFilename /*= __FILE__*/, int nLine /*= __LINE__*/) 
 : m_cs(lock.GetRawCS())
{
	EnterCriticalSection(&m_cs);
}

CScopedLock::~CScopedLock()
{
	LeaveCriticalSection(&m_cs);
}

/// basic check by fan05